/*
 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_ROSEN_DECORATION_PAINTER_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_ROSEN_DECORATION_PAINTER_H

#include <math.h>

#include "base/memory/ace_type.h"
#include "base/utils/utils.h"
#include "core/components/common/layout/constants.h"
#include "core/components/common/properties/border.h"
#include "core/components/common/properties/border_edge.h"
#include "core/components/common/properties/border_image_edge.h"
#include "core/components/common/properties/decoration.h"
#include "core/components/common/properties/edge.h"
#ifndef USE_ROSEN_DRAWING
#include "core/components_ng/render/adapter/skia_decoration_painter.h"
#include "include/core/SkRefCnt.h"
#else
#include "core/components_ng/render/adapter/rosen/drawing_decoration_painter.h"
#endif

#ifndef USE_ROSEN_DRAWING
class SkPath;
class SkPaint;
class SkRRect;
class SkShader;
class SkImage;
struct SkSize;
#endif

namespace Keels::Ace {

class Border;
class Offset;
class Size;

#ifndef USE_ROSEN_DRAWING
class RosenDecorationPainter : public virtual NG::SkiaDecorationPainter {
    DECLARE_ACE_TYPE(RosenDecorationPainter, NG::SkiaDecorationPainter);
#else
class RosenDecorationPainter : public virtual NG::DrawingDecorationPainter {
    DECLARE_ACE_TYPE(RosenDecorationPainter, NG::DrawingDecorationPainter);
#endif

public:
#ifndef USE_ROSEN_DRAWING
    static void PaintShadow(const SkPath& path, const Shadow& shadow, SkCanvas* canvas, const SkPaint* paint = nullptr);

    static void PaintShadow(const SkPath& path, const Shadow& shadow, const std::shared_ptr<RSNode>& rsNode);

    static void PaintGrayScale(
        const SkRRect& outerRRect, SkCanvas* canvas, const Dimension& grayscale, const Color& color);

    static void PaintBrightness(
        const SkRRect& outerRRect, SkCanvas* canvas, const Dimension& brightness, const Color& color);

    static void PaintContrast(
        const SkRRect& outerRRect, SkCanvas* canvas, const Dimension& contrast, const Color& color);

    static void PaintSaturate(
        const SkRRect& outerRRect, SkCanvas* canvas, const Dimension& saturate, const Color& color);

    static void PaintSepia(const SkRRect& outerRRect, SkCanvas* canvas, const Dimension& sepia, const Color& color);

    static void PaintInvert(const SkRRect& outerRRect, SkCanvas* canvas, const Dimension& invert, const Color& color);

    static void PaintHueRotate(const SkRRect& outerRRect, SkCanvas* canvas, const float& hueRotate, const Color& color);

    void PaintDecoration(const Offset& offset, SkCanvas* canvas, RenderContext& context, const sk_sp<SkImage>& image);

    void PaintDecoration(const Offset& offset, SkCanvas* canvas, RenderContext& context);
#else
    static void PaintShadow(const RSPath& path, const Shadow& shadow, RSCanvas* canvas, const RSBrush* brush = nullptr,
        const RSPen* pen = nullptr);
    static void PaintShadow(const RSPath& path, const Shadow& shadow, const std::shared_ptr<RSNode>& rsNode);
    static void PaintGrayScale(
        const RSRoundRect& outerRRect, RSCanvas* canvas, const Dimension& grayscale, const Color& color);
    static void PaintBrightness(
        const RSRoundRect& outerRRect, RSCanvas* canvas, const Dimension& brightness, const Color& color);
    static void PaintContrast(
        const RSRoundRect& outerRRect, RSCanvas* canvas, const Dimension& contrast, const Color& color);
    static void PaintSaturate(
        const RSRoundRect& outerRRect, RSCanvas* canvas, const Dimension& saturate, const Color& color);
    static void PaintSepia(const RSRoundRect& outerRRect, RSCanvas* canvas, const Dimension& sepia, const Color& color);
    static void PaintInvert(
        const RSRoundRect& outerRRect, RSCanvas* canvas, const Dimension& invert, const Color& color);
    static void PaintHueRotate(
        const RSRoundRect& outerRRect, RSCanvas* canvas, const float& hueRotate, const Color& color);
#endif

    static void PaintBoxShadows(const std::vector<Shadow>& shadows, const std::shared_ptr<RSNode>& rsNode);

    static void AdjustBorderStyle(Border& border);

    static void PaintBorder(std::shared_ptr<RSNode>& rsNode, Border& border, double dipScale);

#ifndef USE_ROSEN_DRAWING
    static void PaintColorBlend(
        const SkRRect& outerRRect, SkCanvas* canvas, const Color& colorBlend, const Color& color);
#else
    static void PaintColorBlend(
        const RSRoundRect& outerRRect, RSCanvas* canvas, const Color& colorBlend, const Color& color);
#endif
};

} // namespace Keels::Ace

#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_PAINTER_ROSEN_DECORATION_PAINTER_H
